/*
 * Created by SharpDevelop.
 * User: ronnie.liu
 * Date: 2010-6-10
 * Time: 15:07
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Collections;
using System.Collections.Generic;

namespace ECCIT
{
	/// <summary>
	/// Description of 
	/// </summary>
	[Serializable]
	public class BaseTree
	{
		private BaseTreeNode _rootNode;

		public BaseTreeNode RootNode
		{
			get{ return _rootNode; }
			set{ _rootNode = value; }
		}

		public BaseTree()
		{
			//
			// TODO: Add constructor logic here
			//
		}
	}

	[Serializable]
	public class BaseTreeNode
	{
		private string _id;
		//private int _index;
		//private object _tag;
		private object _value;
		private string _text;
		private List<BaseTreeNode> _childNodes;
		private BaseTreeNode _parentNode;
	
		public string ID
		{
			get{ return _id; }
			set{ _id = value; }
		}

		public BaseTreeNode ParentNode
		{
			get{ return _parentNode; }
			set{ _parentNode = value; }
		}

		public string Text
		{
			get{ return _text; }
			set{ _text = value; }
		}

		public object Value
		{
			get{ return _value; }
			set{ _value = value; }
		}

		public List<BaseTreeNode> Nodes
		{
			get{ return _childNodes; }
			set{ _childNodes = value; }
		}

		public BaseTreeNode(string id, object nodeValue)
		{
			_id = id;
			_value = nodeValue;
		}

		public BaseTreeNode(string id, object nodeValue, string nodeText) : this(id, nodeValue)
		{
			_text = nodeText;
		}

		public void Add(BaseTreeNode childNode)
		{
			childNode.ParentNode = this;
            if (_childNodes == null)
                _childNodes = new List<BaseTreeNode>();

			_childNodes.Add(childNode);
		}

		public override string ToString()
		{
			return this.Text;
		}

	}
}
